package _5Recursion.src.MultiRecursion;

import java.util.LinkedList;
//移动2的n次方-1次
public class hannuota {
    private static LinkedList<Integer> a = new LinkedList<>();
    private static LinkedList<Integer> b = new LinkedList<>();
    private static LinkedList<Integer> c = new LinkedList<>();
    private static int sum=0;

    //初始化内容
    public static void init(int n) {
        for (int i = n; i >=1; i--) {
            a.add(i);
        }
    }

    //开始设置汉诺塔具体处理
    public static void move(int n, LinkedList<Integer> a, LinkedList<Integer> b, LinkedList<Integer> c) {
        if (n == 0) {
            return;
        }
        //把n-1个盘子由a到b
        move(n - 1, a, c, b);
        //把最后的盘子由a到c
        c.addLast(a.removeLast());
        //把n-1个盘子由b借c
        move(n - 1, b, a, c);
        sum++;
    }

    public static void main(String[] args) {
        init(5);
        System.out.println(a);
        move(5,a,b,c);
        System.out.println(sum);
        System.out.println(c);
       /* Integer x = a.removeLast();
        System.out.println(x);*/
    }

}
